<template>
  <div class="supplier-management">
    <!-- 操作栏：新增按钮 + 搜索 -->
    <div class="operation-bar">
      <el-button type="primary" icon="el-icon-plus">新增供应商</el-button>
      <div class="search-group" style="margin-left: auto;">
        <el-input placeholder="请输入供应商名称/联系人" style="width: 240px;" />
        <el-button type="primary" icon="el-icon-search"></el-button>
        <el-button type="primary" icon="el-icon-filter"></el-button>
      </div>
    </div>

    <!-- 供应商表格 -->
    <el-table :data="tableData" border style="width: 100%; margin-bottom: 20px;">
      <el-table-column label="序号" type="index" width="50" />
      <el-table-column prop="supplierName" label="供应商名称" width="120" />
      <el-table-column prop="contact" label="联系人" width="100" />
      <el-table-column prop="phone" label="联系电话" width="120" />
      <el-table-column prop="email" label="邮箱" width="150" />
      <el-table-column prop="address" label="地址" width="200" />
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <el-button type="text" size="small">修改</el-button>
          <el-button type="text" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <div class="pagination-wrap">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
        :page-sizes="[10, 20, 30, 40]" :page-size="10" layout="prev, pager, next, ->, jumper, ->, sizes, total"
        :total="90" />
    </div>
  </div>
</template>

<script>
export default {
  name: 'SupplierManagement',
  data() {
    return {
      currentPage: 1,
      tableData: [
        {
          supplierName: 'XXXX公司',
          contact: '李晓琪',
          phone: '18898888888',
          email: 'ppp@zuy.com',
          address: '成都市武侯区XXXX路XXX号'
        },
        {
          supplierName: 'XXXX公司',
          contact: '李晓琪',
          phone: '18898888888',
          email: 'ppp@zuy.com',
          address: '成都市武侯区XXXX路XXX号'
        },
        {
          supplierName: 'XXXX公司',
          contact: '李晓琪',
          phone: '18898888888',
          email: 'ppp@zuy.com',
          address: '成都市武侯区XXXX路XXX号'
        },
        {
          supplierName: 'XXXX公司',
          contact: '李晓琪',
          phone: '18898888888',
          email: 'ppp@zuy.com',
          address: '成都市武侯区XXXX路XXX号'
        },
        {
          supplierName: 'XXXX公司',
          contact: '李晓琪',
          phone: '18898888888',
          email: 'ppp@zuy.com',
          address: '成都市武侯区XXXX路XXX号'
        },
        {
          supplierName: 'XXXX公司',
          contact: '李晓琪',
          phone: '18898888888',
          email: 'ppp@zuy.com',
          address: '成都市武侯区XXXX路XXX号'
        },
        {
          supplierName: 'XXXX公司',
          contact: '李晓琪',
          phone: '18898888888',
          email: 'ppp@zuy.com',
          address: '成都市武侯区XXXX路XXX号'
        },
        {
          supplierName: 'XXXX公司',
          contact: '李晓琪',
          phone: '18898888888',
          email: 'ppp@zuy.com',
          address: '成都市武侯区XXXX路XXX号'
        },
        {
          supplierName: 'XXXX公司',
          contact: '李晓琪',
          phone: '18898888888',
          email: 'ppp@zuy.com',
          address: '成都市武侯区XXXX路XXX号'
        },
        {
          supplierName: 'XXXX公司',
          contact: '李晓琪',
          phone: '18898888888',
          email: 'ppp@zuy.com',
          address: '成都市武侯区XXXX路XXX号'
        }
      ]
    }
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val;
    }
  }
}
</script>

<style scoped>
.supplier-management {
  padding: 20px;
}

.operation-bar {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.search-group {
  display: flex;
  align-items: center;
}

.search-group .el-input {
  margin-right: 8px;
}

.pagination-wrap {
  display: flex;
  justify-content: flex-end;
}
</style>